﻿using System;
using System.Data;
using System.Collections.Generic;
using ElingOA6_DSJCJ.Model;
namespace ElingOA6_DSJCJ.BLL
{
	/// <summary>
	/// PaperAnswer
	/// </summary>
	public partial class PaperAnswer
	{
		private readonly ElingOA6_DSJCJ.DAL.PaperAnswer dal=new ElingOA6_DSJCJ.DAL.PaperAnswer();
		public PaperAnswer()
		{}
		#region  Method
		/// <summary>
		/// 是否存在该记录
		/// </summary>
		public bool Exists(decimal FPaperTopicId,decimal FPaperAnswerManagerID)
		{
			return dal.Exists(FPaperTopicId,FPaperAnswerManagerID);
		}

		/// <summary>
		/// 增加一条数据
		/// </summary>
		public bool Add(ElingOA6_DSJCJ.Model.PaperAnswer model)
		{
			return dal.Add(model);
		}
        public void AddItem(Model.PaperAnswerManager paperAnswerManagerModel, List<Model.PaperAnswer> paperAnswerList)
        {
            dal.AddItem(paperAnswerManagerModel, paperAnswerList);
        }
		/// <summary>
		/// 更新一条数据
		/// </summary>
		public bool Update(ElingOA6_DSJCJ.Model.PaperAnswer model)
		{
			return dal.Update(model);
		}

		/// <summary>
		/// 删除一条数据
		/// </summary>
		public bool Delete(decimal FPaperTopicId,decimal FPaperAnswerManagerID)
		{
			
			return dal.Delete(FPaperTopicId,FPaperAnswerManagerID);
		}

		/// <summary>
		/// 得到一个对象实体
		/// </summary>
		public ElingOA6_DSJCJ.Model.PaperAnswer GetModel(decimal FPaperTopicId,decimal FPaperAnswerManagerID)
		{
			
			return dal.GetModel(FPaperTopicId,FPaperAnswerManagerID);
		}

		/// <summary>
		/// 获得数据列表
		/// </summary>
		public DataSet GetList(string strWhere)
		{
			return dal.GetList(strWhere);
		}


		/// <summary>
		/// 获得前几行数据
		/// </summary>
		public DataSet GetList(int Top,string strWhere,string filedOrder)
		{
			return dal.GetList(Top,strWhere,filedOrder);
		}
		/// <summary>
		/// 获得数据列表
		/// </summary>
		public List<ElingOA6_DSJCJ.Model.PaperAnswer> GetModelList(string strWhere)
		{
			DataSet ds = dal.GetList(strWhere);
			return DataTableToList(ds.Tables[0]);
		}
		/// <summary>
		/// 获得数据列表
		/// </summary>
		public List<ElingOA6_DSJCJ.Model.PaperAnswer> DataTableToList(DataTable dt)
		{
			List<ElingOA6_DSJCJ.Model.PaperAnswer> modelList = new List<ElingOA6_DSJCJ.Model.PaperAnswer>();
			int rowsCount = dt.Rows.Count;
			if (rowsCount > 0)
			{
				ElingOA6_DSJCJ.Model.PaperAnswer model;
				for (int n = 0; n < rowsCount; n++)
				{
					model = new ElingOA6_DSJCJ.Model.PaperAnswer();
					if(dt.Rows[n]["FPaperTopicId"]!=null && dt.Rows[n]["FPaperTopicId"].ToString()!="")
					{
						model.FPaperTopicId=decimal.Parse(dt.Rows[n]["FPaperTopicId"].ToString());
					}
					if(dt.Rows[n]["FAnswer"]!=null && dt.Rows[n]["FAnswer"].ToString()!="")
					{
					model.FAnswer=dt.Rows[n]["FAnswer"].ToString();
					}
					if(dt.Rows[n]["FIsCorrect"]!=null && dt.Rows[n]["FIsCorrect"].ToString()!="")
					{
						model.FIsCorrect=decimal.Parse(dt.Rows[n]["FIsCorrect"].ToString());
					}
					if(dt.Rows[n]["FWriteAnswer"]!=null && dt.Rows[n]["FWriteAnswer"].ToString()!="")
					{
					model.FWriteAnswer=dt.Rows[n]["FWriteAnswer"].ToString();
					}
					if(dt.Rows[n]["FPaperAnswerManagerID"]!=null && dt.Rows[n]["FPaperAnswerManagerID"].ToString()!="")
					{
						model.FPaperAnswerManagerID=decimal.Parse(dt.Rows[n]["FPaperAnswerManagerID"].ToString());
					}
					modelList.Add(model);
				}
			}
			return modelList;
		}

		/// <summary>
		/// 获得数据列表
		/// </summary>
		public DataSet GetAllList()
		{
			return GetList("");
		}

		/// <summary>
		/// 分页获取数据列表
		/// </summary>
		public int GetRecordCount(string strWhere)
		{
			return dal.GetRecordCount(strWhere);
		}
		/// <summary>
		/// 分页获取数据列表
		/// </summary>
		public DataSet GetListByPage(string strWhere, string orderby, int startIndex, int endIndex)
		{
			return dal.GetListByPage( strWhere,  orderby,  startIndex,  endIndex);
		}
		/// <summary>
		/// 分页获取数据列表
		/// </summary>
		//public DataSet GetList(int PageSize,int PageIndex,string strWhere)
		//{
			//return dal.GetList(PageSize,PageIndex,strWhere);
		//}
        /// <summary>
        /// 获得数据列表
        /// </summary>
        public DataSet GetListGroupByAnswer(decimal FPaperTopicId)
        {
            return dal.GetListGroupByAnswer(FPaperTopicId);
        }
		#endregion  Method
	}
}

